package com.xiaoyu.izf.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "region", schema = "izf", catalog = "")
public class Region {
    private int regionId;
    private String regionCode;
    private String regionName;
    private int parentId;
    private String regionNameEn;
    private String regionShortnameEn;
    private Integer soldOut;

    private List<Region> children;

    @Transient
    public List<Region> getChildren() {
        return children;
    }
    public void setChildren(List<Region> children) {
        this.children = children;
    }

    @Id
    @Column(name = "region_id")
    public int getRegionId() {
        return regionId;
    }

    public void setRegionId(int regionId) {
        this.regionId = regionId;
    }

    @Basic
    @Column(name = "region_code")
    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    @Basic
    @Column(name = "region_name")
    public String getRegionName() {
        return regionName;
    }

    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    @Basic
    @Column(name = "parent_id")
    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    @Basic
    @Column(name = "region_name_en")
    public String getRegionNameEn() {
        return regionNameEn;
    }

    public void setRegionNameEn(String regionNameEn) {
        this.regionNameEn = regionNameEn;
    }

    @Basic
    @Column(name = "region_shortname_en")
    public String getRegionShortnameEn() {
        return regionShortnameEn;
    }

    public void setRegionShortnameEn(String regionShortnameEn) {
        this.regionShortnameEn = regionShortnameEn;
    }

    @Basic
    @Column(name = "sold_out")
    public Integer getSoldOut() {
        return soldOut;
    }
    public void setSoldOut(Integer soldOut) {
        this.soldOut = soldOut;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Region that = (Region) o;
        return regionId == that.regionId &&
                parentId == that.parentId &&
                Objects.equals(regionCode, that.regionCode) &&
                Objects.equals(regionName, that.regionName) &&
                Objects.equals(regionNameEn, that.regionNameEn) &&
                Objects.equals(regionShortnameEn, that.regionShortnameEn);
    }

    @Override
    public int hashCode() {
        return Objects.hash(regionId, regionCode, regionName, parentId, regionNameEn, regionShortnameEn);
    }
}
